package com.project.music.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.music.bean.Admin;
import com.project.music.mapper.AdminMapper;
import com.project.music.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public boolean verify(String name, String password) {

        QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                    .select(Admin::getId)
                    .eq(Admin::getName, name)
                    .eq(Admin::getPassword, password);

        int count = adminMapper.selectCount(queryWrapper);
        return (count != 0);
    }
}
